<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var text="cat,bat,sat,fat";
    var pattern1=/.at/g;
    var matches=pattern1.exec(text);
    var matches1=pattern1.exec(text);
    var matches2=pattern1.exec(text);
    var matches3=pattern1.exec(text);
    var matches4=pattern1.exec(text);

    console.log(matches)
    console.log(matches1)
    console.log(matches2)
    console.log(matches3)
    console.log(matches4)
//    console.log(matches.index);//0
//    console.log(matches[0]);//cat
//    console.log(pattern1.lastIndex);//3



     matches=pattern1.exec(text);
//    console.log(matches)
//    console.log(matches.index);//5
//    console.log(matches[0]);//bat
//    console.log(pattern1.lastIndex);//7


//    var str = "abc123";
//    var re = /a.c/g
//    var result1 = re.test(str);
//    var result2 = re.test(str);
//    var result3 = re.test(str);
//    var result4 = re.test(str);
//    var result5 = re.test(str);
//    var result6 = re.test(str);
//    console.log(result1)
//    console.log(result2)
//    console.log(result3)
//    console.log(result4)
//    console.log(result5)
//    console.log(result6)


</script>
</body>
</html>